<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
    var t = async_test('Make sure that source based image resources are not downloaded after the source is removed from the DOM.');
</script>
<iframe id=frame src="resources/image-picture-no-download-after-picture-removal-frame.html" width="700px"></iframe>
<script>
    window.addEventListener("message", t.step_func(function(msg) {
        if (msg.data == "shrink") {
            document.getElementsByTagName("iframe")[0].width = "150px";
        } else if (msg.data.indexOf("test_") != -1) {
            assert_equals(msg.data, "test_1");
            t.done();
        }
    }));

    // Since we want to see that a new resource wasn't downloaded, the only way is a timeout.
    setTimeout(t.step_func(function() {
        document.getElementById("frame").contentWindow.postMessage("test", "*");
    }), 500);
</script>
